import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AutoScaleAnim')
export class AutoScaleAnim extends Component {

    @property
    time = 0.5;
    @property
    salceStep = 0.2;

    curTime = 0;
    onEnable(): void {
        this.curTime = 0;
    }
    update(dt: number) {

        this.curTime += dt;

        if (this.curTime > this.time) {
            this.curTime = 0;
        }

        let r = Math.sin((this.curTime / this.time) * Math.PI);
        let s = 1 + r * this.salceStep;
        this.node.setScale(s, s, 1);
    }
}

